﻿// 1.1.4.13. Write a program to calculate the sum (with accuracy of 0.001): 1 + 1/2 - 1/3 + 1/4 - 1/5 + ...

using System;

class SummingFractions
{
    static void Main()
    {
        double oldSum = 0f;
        double sum = 1f;
        double i = 2f;
        while (sum - oldSum >= 0.001f || oldSum - sum >= 0.001f)
        {
            oldSum = sum;
            if (i % 2 == 0)
            {
                sum += 1 / i;
            }
            else
            {
                sum -= 1 / i;
            }
            i++;
        }
        Console.WriteLine("{0:F4}, {1:F4}", sum, sum - oldSum);
    }
}